<?php

namespace App\Model\Report;

use App\Model\Model;
use Carbon\Carbon;

class ReportThirdLog extends Model
{
    protected ?string $table = "report_third_log";

    protected array $casts = [
        'req_json' => 'array',
        'resp_json' => 'array'
    ];

    public static function insertData($projectId, $appId, $ascribeChannelType, $ascribeChannel, $version, $adId, $adPlanId,
                               $oaid, $eventType, $reqUrl, $reqJson, $respCode, $respJson): void
    {
        self::create([
            'project_id' => $projectId,
            'app_id' => $appId,
            'ascribe_channel_type' => $ascribeChannelType,
            'ascribe_channel' => $ascribeChannel,
            'version' => $version,
            'ad_id' => $adId,
            'ad_plan_id' => $adPlanId,
            'oaid' => $oaid,
            'event_type' => $eventType,
            'req_url' => $reqUrl,
            'req_json' => $reqJson,
            'resp_code' => $respCode,
            'resp_json' => $respJson,
            'date' => Carbon::today()->toDateString(),
        ]);
    }
}